<?php

/**
 * This is the model class for table "product".
 *
 * The followings are the available columns in table 'product':
 * @property string $id
 * @property string $category
 * @property string $category_ids
 * @property string $brand_id
 * @property string $product_name
 * @property string $url_key
 * @property string $product_code
 * @property string $old_price
 * @property string $new_price
 * @property string $last_update
 * @property string $content
 * @property string $hits
 * @property integer $is_hot
 * @property integer $is_new
 * @property string $tagged
 * @property string $sorder
 * @property integer $status
 * @property integer $blogspot
 */
class ProductPeer extends CActiveRecord
{
	var $className = __CLASS__;
	/**
	 * Returns the static model of the specified AR class.
	 * @return ProductPeer the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'product';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('product_name, url_key', 'required'),
			array('is_hot, is_new, status, blogspot', 'numerical', 'integerOnly'=>true),
			array('category, brand_id, last_update, hits, sorder', 'length', 'max'=>20),
			array('category_ids, product_name, url_key, tagged', 'length', 'max'=>300),
			array('product_code, old_price, new_price', 'length', 'max'=>100),
			array('content', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, category, category_ids, brand_id, product_name, url_key, product_code, old_price, new_price, last_update, content, hits, is_hot, is_new, tagged, sorder, status, blogspot', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return Common::loadMessages("BackEnd");
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);

		$criteria->compare('category',$this->category,true);

		$criteria->compare('category_ids',$this->category_ids,true);

		$criteria->compare('brand_id',$this->brand_id,true);

		$criteria->compare('product_name',$this->product_name,true);

		$criteria->compare('url_key',$this->url_key,true);

		$criteria->compare('product_code',$this->product_code,true);

		$criteria->compare('old_price',$this->old_price,true);

		$criteria->compare('new_price',$this->new_price,true);

		$criteria->compare('last_update',$this->last_update,true);

		$criteria->compare('content',$this->content,true);

		$criteria->compare('hits',$this->hits,true);

		$criteria->compare('is_hot',$this->is_hot);

		$criteria->compare('is_new',$this->is_new);

		$criteria->compare('tagged',$this->tagged,true);

		$criteria->compare('sorder',$this->sorder,true);

		$criteria->compare('status',$this->status);

		$criteria->compare('blogspot',$this->blogspot);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}